package com.game.World.Logical;

import java.io.IOException;


/**
 * Class are factory of class Room which is return a some kind of chamber from file
 * @author Max
 *
 */
public class ChamberCreator {
	
	/**
	 * Constant of count chambers
	 */
	public static final int CHAMBERS_COUNT = 2;
	
	/**
	 *Root catalog of all files with chambers
	 */
	private static final String root = "bin/data/chambers/";
	
	
	
	/**
	 * Static factory method which returns some kind of Room by number k
	 * @param k - number of chamber
	 * @return - Room (which contains some chamber)
	 * @throws IOException - works with files
	 */
	public static Room getChamber(int size,int k) throws IOException {
		
		String file;
		
		if (k>=CHAMBERS_COUNT) 
			k = k % CHAMBERS_COUNT;
		
		switch (k) {
		case 0:
			file = "ch_0.txt";
			break;
		case 1:
			file = "ch_1.txt";
			break;
		default:
			file = "ch_0.txt";
		}
		
		return new Room(root+file);
	}

}
